<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>添加市场信息-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.checktitle{width: 80px;text-align: right;float: left;font-size: 14px;}
	.checkitem{ padding-left: 75px; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
	<div id="main">
		<div class="crumbs">
			<div class="crumbs-text">市场信息表 > 添加市场信息</div>
		</div>
		<div id="content">
			<form action="__APP__/Project/customer_information_add" method="post" id="project_add_form">
				<input type="hidden" name="action" value="add">
				<input type="hidden" name="center_ids" value="{$center_ids}">
				<div class="form-main">
					<div class="form-title">添加市场信息</div>
					<div class="form-item">
						<div class="input-label">所属中心</div>
						<div class="input-item">
							{:get_center_name($center_ids)}
						</div>
					</div>
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>市场信息名称</div>
						<div class="input-item">
							<input type="text" class="form-control required_text w300" name="customer_name" autocomplete="off">
							<span class="error-item">必填项</span>
						</div>
					</div>
					<!--<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>所属中心</div>
						<div class="input-item checkbox_zx">
							<volist name="centers" id="vo">
								<label class="checkbox-inline">
									<input type="checkbox" value="{$vo['id']}" name="center_id[]" autocomplete="off">{$vo['first_name']}
								</label>
							</volist>
							<span class="error-item">必填项</span>
						</div>
					</div>-->
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>获悉渠道</div>
						<div class="input-item">
							<input type="hidden" class="link_status">
							<select name="channel" class="form-control w150 required_select" autocomplete="off">
								<option value="-10">请选择</option>
								<foreach name="channels[0]['second'][0]['third']" item="vo">
								<option value="{$vo['id']}">{$vo['third_name']}</option>
								</foreach>
							</select>
							
							<input type="text" name="channel_new" class="form-control select-add-text marginLeft5" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">该分类已存在</span>
							
							<input type="text" class="`marginLeft10 hide channel_remark" maxlength="50" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="f12 marginLeft5 c999 channel_remark_info">不能超过50字</span>
						</div>
					</div>
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>市场信息等级</div>
						<div class="input-item checkbox_level">
							<label class="checkbox-inline"><input type="checkbox" value="集团战略合作项目" name="project_level[]" autocomplete="off">集团战略合作项目</label>
							<label class="checkbox-inline"><input type="checkbox" value="重点关注项目" name="project_level[]" autocomplete="off">重点关注项目</label>
							<label class="checkbox-inline"><input type="checkbox" value="其它" name="project_level[]" autocomplete="off">其它</label>
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>市场信息类型</div>
						<div class="input-item checkbox_validate">
							<foreach name="type_list" item="f">
								<div>
									<span class="checktitle" value="{$f['id']}">{$f['second_name']}：</span>
									<div class="checkitem">
										<foreach name="f['third']" item="s">
											<label class="checkbox-inline"><input type="checkbox" value="{$s['id']}" name="customer_type[]" autocomplete="off">{$s['third_name']}</label>
										</foreach>
									</div>
								</div>
							</foreach>
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>启动日期</div>
						<div class="input-item">
							<input type="text" name="start_date" class="form-control Wdate w100 required_text" onClick="WdatePicker()" readonly autocomplete="off">
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="form-item">
						<div class="input-label">有效性</div>
						<div class="input-item">
							<label class="radio-inline">
								<input value="1" type="radio" name="effective" checked autocomplete="off">是
							</label>
							<label class="radio-inline">
								<input value="-1" type="radio" name="effective" autocomplete="off">否
							</label>
						</div>
					</div>
				</div>
				<div class="form-btn-item"><input type="submit" value="提交" class="btn btn-submit"><button class="btn btn-default goback" type="button">返回</button></div>
			</form>
		</div>
	</div>
</body>
<include file="Include:javascript" />
<script type="text/javascript">
	$(function() {
		/*表单验证*/
		$(".btn-submit").click(function(){
			var flag = false,
				flag2 = true,
				flag4 = true;
				
			$(".required_text").each(function(){
				if($(this).val()==""){
					$(this).next(".error-item").show();
					flag = true;
				}
			});
			$("select.required_select").each(function(){
				var $this = $(this),
					val = $this.val(),
					text = $this.nextAll(".select-add-text").val();
				if(val==-10 && (text=="" || /^\s+$/.test(text))){
					$this.nextAll(".error-item").eq(0).show();
					flag = true;
				}if(text=="全部"){
					$this.nextAll(".error-item").eq(1).show()
					flag = true;
				}else{
					$this.find("option").each(function(){
						if($(this).text()==text){
							$this.nextAll(".error-item").eq(1).show()
							flag = true;
							return false;
						}
					});
				}
			});
			$("[name='link_user']").each(function(){
				if($(this).val()==""){
					$(this).parent().nextAll(".error-item").show();
					flag = true;
				}
			});
			$(".channel_remark").each(function(){
				if($(this).is(":visible") && $(this).val()==""){
					$(this).nextAll(".error-item").show();
					flag = true;
				}
			});
			$(".checkbox_validate :checkbox").each(function(){
				if($(this).prop("checked")){
					flag2 = false;
				}
			});
			/*
			$(".checkbox_zx :checkbox").each(function(){
				if($(this).prop("checked")){
					flag3 = false;
				}
			});
			*/
			$(".checkbox_level :checkbox").each(function(){
				if($(this).prop("checked")){
					flag4 = false;
				}
			});
			
			if(flag2){
				$(".checkbox_validate").find(".error-item").show();
			}
			/*
			if(flag3){
				$(".checkbox_zx").find(".error-item").show();
			}
			*/
			if(flag4){
				$(".checkbox_level").find(".error-item").show();
			}
			if(flag||flag2||flag3||flag4){
				return false;
			}
		});
		/*取消错误提示*/
		$(".required_text,.channel_remark").on("focus",function(){
			$(this).nextAll(".error-item").hide();
		});
		$(".required_select").on("change",function(){
			$(this).nextAll(".error-item").hide();
		});
		$(".checkbox_validate :checkbox").click(function(){
			$(".checkbox_validate").find(".error-item").hide();
		});
		/*
		$(".checkbox_zx :checkbox").on("click",function(){
			$(".checkbox_zx").find(".error-item").hide();
		});
		*/
		$(".checkbox_level :checkbox").click(function(){
			$(".checkbox_level").find(".error-item").hide();
		});
		$(".link_user_select").on("change",function(){
			$(this).parent().nextAll(".error-item").hide();
		});
		$(".link_user_input").on("focus",function(){
			$(this).parent().nextAll(".error-item").hide();
		});
		//奇创内部推荐联动
		$("select.link_user_select").change(function(){
			var $val = $(this).val(),
				$input = $(".link_user_input"),
				$type = $(".link_status");

			if($val==-10){
				$(this).removeAttr("name");
				$input.show();
				$input.attr("name","link_user");
				$type.attr("name","link_status").val("-10");
			}else{
				$(this).attr("name","link_user");
				$input.hide();
				$input.removeAttr("name").val("");
				$type.attr("name","link_status").val("1");
			}
		});
		$("[name='channel']").change(function(){
			var $val = $(this).val(),
				$link_user = $(".link_user"),
				$input = $(".link_user_input"),
				$select = $("select.link_user_select"),
				$type = $(".link_status"),
				$channel_remark = $(".channel_remark"),
				$channel_remark_info = $(".channel_remark_info");

			if($val=="内部推荐"){
				$link_user.show();
				$input.show();
				$input.attr("name","link_user");
				$("select.link_user_select").change();
			}else{
				$link_user.hide();
				$input.removeAttr("name").val("");
				$select.removeAttr("name").val("-10").select2();
				$type.removeAttr("name").val("");
			}
			if($val=="集团大市场部" || $val=="老客户推荐" || $val=="老客户延伸" || $val=="驴妈妈分公司" || $val=="其它" || $val=="集团各事业版块" || $val=="上下游合作伙伴"){
				$channel_remark.show().attr("name","channel_remark");
				$channel_remark_info.show();
			}else{
				$channel_remark.hide().val("").removeAttr("name");
				$channel_remark_info.hide();
			}
		});
		$("[name='channel']").change();
		
		//标签选择事件
		$("select.required_select").on('change',function(){
			var val = $(this).val(),
				text = $(this).nextAll(".select-add-text");
			if(val==-10){
				text.show();
			}else{
				text.hide().val("").nextAll(".error-item").hide();
			}
		});
	});
</script>
</html>